﻿package controller;

import bean.LiveBroadcastInfo;
import biz.LiveBroadcastBiz;
import com.alibaba.fastjson.JSONArray;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import util.PreAddCallback;

import java.util.List;

@Controller
@RequestMapping("/livebroadcast")
public class LiveBroadcastController {
    @Autowired
    private LiveBroadcastBiz lbb;
    //找所有直播
    @RequestMapping(value="/findAllLiveBroadcast" )
    @ResponseBody
    public String  findAllLiveBroadcast(String callback) {

        return PreAddCallback.preAddCallback(JSONArray.toJSONString(lbb.findAllLiveBroadcast()),callback);
    }
    //通过直播号找直播
    @RequestMapping(value="/findLiveBroadcastByLiveBroadcastNumber" )
    @ResponseBody
    public String  findLiveBroadcastByLiveBroadcastNumber(Integer liveBroadcastNumber,String callback){
        return PreAddCallback.preAddCallback(JSONArray.toJSONString(lbb.findLiveBroadcastByLiveBroadcastNumber(liveBroadcastNumber)),callback);
    }

    //插入在线人数
    @RequestMapping(value="/addOnlineNumber")
    @ResponseBody
    public  String addOnlineNumber(Integer liveBroadcastNumber , Integer statement){

        lbb.addOnlineNumber(1,1);
        return  "插入在线人数！！";
    }

    //显示在线人数
    @RequestMapping(value="/showOnlineNumber" )
    @ResponseBody
    public   String showOnlineNumber( Integer liveBroadcastNumber,String callback){
        return PreAddCallback.preAddCallback(JSONArray.toJSONString( lbb.showOnlineNumber(liveBroadcastNumber)),callback);
    }

    //插入答题人数
    @RequestMapping(value="/addAnswerNumber")
    @ResponseBody
    public  String addAnswerNumber( Integer liveBroadcastNumber , Integer statement){
        lbb.addAnswerNumber(1,1);
        return  "插入答题人数！！";
    }

    //    //显示答题人数
    @RequestMapping(value="/showAnswerNumber")
    @ResponseBody
    public  String showAnswerNumber(  Integer liveBroadcastNumber,String callback){
        return PreAddCallback.preAddCallback(JSONArray.toJSONString(lbb.showAnswerNumber(liveBroadcastNumber)),callback);
    }

    //插入获奖人数
    @RequestMapping(value="/addWinNumber")
    @ResponseBody
    public  String addWinNumber(@Param("liveBroadcastNumber") Integer liveBroadcastNumber ,  Integer statement){
        lbb.addWinNumber(1,1);
        return  "插入获奖人数！！";
    }

    //显示获奖人数
    @RequestMapping(value="/showWinNumber")
    @ResponseBody
    public String showWinNumber(Integer liveBroadcastNumber,String callback){
        return PreAddCallback.preAddCallback(JSONArray.toJSONString(lbb.showWinNumber(liveBroadcastNumber)),callback);
    }




}
